package com.younio.local.repository;

import com.younio.local.annotation.DataSource;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface SynDerbyMysqlMapper {

    @DataSource("mysql")
    Integer maxMysql(@Param("tableName") String tableName, @Param("mac") String mac);

    @DataSource("derby")
    Integer maxDerby(@Param("tableName") String tableName);

    @DataSource("derby")
    List<Map> findMore(@Param("tableName") String tableName, @Param("from") Integer from);

    @DataSource("mysql")
    void batchInsert(@Param("tableName") String tableName,
                     @Param("mac") String mac,
                     @Param("mapList") List<Map> mapList);

    @DataSource("mysql")
    Integer getBaseIndex(@Param("tableName") String tableName, @Param("mac") String mac);

    @DataSource("mysql")
    void createBaseIndex(@Param("tableName") String tableName,
                         @Param("mac") String mac,
                         @Param("baseIndex") Integer baseIndex);

    @DataSource("derby")
    int count(@Param("tableName") String tableName);

    @DataSource("mysql")
    @Select("SELECT 1 FROM dual")
    int mysqlHeartbeat();

    @DataSource("derby")
    @Select("select 1 from batch_item fetch next 1 rows only")
    int derbyHeartbeat();
}
